<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>
<body>
	<!-- 判断数据类型 -->
	<script>
		//方式一：使用toString.call()来判断
		function dataType(type){
			let regType = /\s(\S*)]/
			let _type=type
			let typeString=toString.call(_type)
			return typeString.match(regType)[1]
		}
		let map=new Map()
		map.set('a',12)
		console.log(dataType({ name: 12 })); 
		console.log(dataType(map));
		console.log(dataType([])); 
		console.log(dataType({})); 
		console.log(dataType(new Set())); 
		console.log(dataType('')); 
		console.log(dataType(new Date())); 
		console.log(dataType(NaN)); 
		console.log(dataType(new RegExp())); 
		//方式二：使用typeof，instanceof，来判断
	</script>
</body>
</html>